package br.com.insula.twithis.processor;

import java.util.Hashtable;

import br.com.insula.twithis.processor.impl.EventProcessor;
import br.com.insula.twithis.processor.impl.ImageProcessor;
import br.com.insula.twithis.processor.impl.MemoProcessor;
import br.com.insula.twithis.processor.impl.MessageProcessor;
import br.com.insula.twithis.processor.impl.ToDoProcessor;

public abstract class ProcessorFactory {

	private static Hashtable names = new Hashtable();

	static {
		names.put("net.rim.blackberry.api.pdap.ToDoImpl", new ToDoProcessor());
		names.put("net.rim.blackberry.api.pdap.MemoImpl", new MemoProcessor());
		names.put("net.rim.blackberry.api.pdap.EventImpl", new EventProcessor());
		names.put("net.rim.blackberry.api.mail.Message", new MessageProcessor());
		names.put("java.lang.String", new ImageProcessor());
	}

	public static Payload process(Object context) {
		String name = context.getClass().getName();

		Processor p = (Processor) names.get(name);

		if (p != null) {
			return p.getPayload(context);
		}

		return null;
	}

}
